<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
	<link rel="stylesheet" href="https://cdn.bootcss.com/ionicons/2.0.1/css/ionicons.min.css">
	<link rel="stylesheet" href="https://cdn.bootcss.com/layer/3.0.1/skin/default/layer.min.css">
	<link rel="stylesheet" href="../../../layui/css/layui.css">
	<link rel="stylesheet" href="../../../css/byking.css">
	<link rel="stylesheet" href="../../../css/jquery.mloading.css">
	
</head>
<body>
    <!-- Main content -->
    <section class="content">
		<div class="byking-panel-content" id="companylist" _table="companylist">
				<div class="byking-panel-head">
					<div class="byking-plane-left">
						<font>顶级组织信息</font>
					</div>
					
					<div class="byking-panel-right">
						<div class="byking-buts">
							<button @click="custom(index,'sureItem')" 
							        class="btn btn-default fa fa-users" 
							        data-toggle="tooltip" 
							        data-original-title="选择组织"></button>
							<button @click="custom(index,'cannelItem')" 
							        class="btn btn-default fa fa-undo" 
							        data-toggle="tooltip" 
							        data-original-title="取消选择"></button>
						</div>
					</div>
					
				</div>
				<table class="byking-table byking-table-bordered">
					<thead  v-if="page != null">
						<tr>
		    				<th>组织名称</th>
		    				<th>组织描述</th>
		    				<th>组织图标</th>
						</tr>
					</thead>
					<tbody>
		    			<tr v-for="(index,item) in page" class="byking-table-tr" id="{{item.guid}}" @click="custom(index,'selectItem')">
		    				<td>{{item.name}}</td>
		    				<td>{{item.description}}</td>
		    				<td>{{item.image}}</td>
		    			</tr>
	  
					</tbody>
				</table>
				<div v-if="total == 0" class="byking-content-empty">
					<font>没有数据</font>
				</div>
			</div>
    </section>

	<!-- jQuery -->
	<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
	<!-- jquery.cookie -->
	<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
	<!-- layer -->
	<script src="https://cdn.bootcss.com/layer/3.0.1/layer.min.js"></script>
	<!-- vue -->
	<script src="http://cdn.jsdelivr.net/vue/1.0.7/vue.min.js"></script>
	<script src="../../../js/byking-data-table.js"></script>
	<script src="../../../js/byking.js"></script>
	<script src="../../../js/hostconfig.js"></script>
	<script src="../../../js/jquery.mloading.js"></script>
	
	<script>
	var selectItem = null;
	
	$tableData.addTable($hostconfig.sysAuthHost+"/department/tops?user_guid="+$byking.getCookieValue("user_guid"), "#companylist", function(index, type, ob){
		if(type === "selectItem") {
			var content = this.page[index];
			selectItem = content;
			$("#"+content.guid).siblings().removeClass("byking-table-tr-select");
			$("#"+content.guid).addClass("byking-table-tr-select");
		}
		if(type === "sureItem") {
			if(selectItem == null) {
				layer.msg("请选择顶级部门", {icon:5});
				return;
			}
			var index = parent.layer.getFrameIndex(window.name);  
			parent.changeTopDep(selectItem);
			parent.layer.close(index);
		} else if (type === "cannelItem") {
			selectItem = {}; 
			selectItem.name = "全部组织";
			var index = parent.layer.getFrameIndex(window.name);  
			parent.changeTopDep(selectItem);
			parent.layer.close(index);
		}
	}, false, true, false, 1, null, true, "#companylist");	
	
</script>

</body>
<script>


</script>
</html>

